<?php

namespace Notice\Controller;

use Common\Controller\BaseController;
use Think\Page;

class IndexController extends BaseController
{
    public function index()
    {
        $model = D('VUserNotice');
        $sp = $_GET['p'];
        if (empty($sp)) {
            $sp = 1;
        }
        $search_key = $_POST['search_key'];
        $status = $_POST['search_status'];
        $user_id = $this->current_user['id'];
        $list = $model->get_list($user_id, $search_key, $status, $sp, C('PAGE_SIZE'));

        $page = new Page($list[1], C('PAGE_SIZE'));

        $this->assign('total_rows', $page->totalRows);
        $this->assign('_page', $page);
        $this->assign('page_link', $page->show());
        $this->assign('notice_list', $list[0]);

        foreach ($_POST as $key => $val) {
            $page->parameter[$key] = urlencode($val);
        }
        $this->display();
    }

    public function detail()
    {
        $id = $_GET['id'];
        $model = D('VUserNotice');
        $r= $model->read($id);
        $user_notice=$model->get($id);

        $this->assign('user_notice', $user_notice);
        $this->display();
    }

}
